#!/usr/bin/env python
# vim:fileencoding=utf-8

from calibre.web.feeds.news import BasicNewsRecipe


class Snob(BasicNewsRecipe):
    title = '\u0421\u043D\u043E\u0431'
    __author__ = 'bugmen00t'
    description = '\u0414\u0438\u0441\u043A\u0443\u0441\u0441\u0438\u043E\u043D\u043D\u043E\u0435, \u0438\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u043E\u043D\u043D\u043E\u0435 \u0438 \u043E\u0431\u0449\u0435\u0441\u0442\u0432\u0435\u043D\u043D\u043E\u0435 \u043F\u0440\u043E\u0441\u0442\u0440\u0430\u043D\u0441\u0442\u0432\u043E \u0434\u043B\u044F \u043B\u044E\u0434\u0435\u0439, \u043A\u043E\u0442\u043E\u0440\u044B\u0435 \u0436\u0438\u0432\u0443\u0442 \u0432 \u0440\u0430\u0437\u043D\u044B\u0445 \u0441\u0442\u0440\u0430\u043D\u0430\u0445, \u0433\u043E\u0432\u043E\u0440\u044F\u0442 \u043D\u0430 \u0440\u0430\u0437\u043D\u044B\u0445 \u044F\u0437\u044B\u043A\u0430\u0445, \u043D\u043E \u0434\u0443\u043C\u0430\u044E\u0442 \u043F\u043E-\u0440\u0443\u0441\u0441\u043A\u0438.'  # noqa
    publisher = '\u041E\u041E\u041E \u00AB\u0421\u043D\u043E\u0431 \u041C\u0435\u0434\u0438\u0430\u00BB'
    category = 'magazine'
    cover_url = u'https://snob.ru/indoc/tilda/995317/images/tild3233-6631-4664-b663-353636373235__e3057a5fee932ada1aaf.png'
    language = 'ru'
    no_stylesheets = False
    remove_javascript = False
    auto_cleanup = False
    oldest_article = 5
    max_articles_per_feed = 50

    remove_tags_before = dict(name='h1')

    remove_tags_after = dict(name='article')

    remove_tags = [
        dict(name='div', attrs={'class': 'entry__tags'}),
        dict(name='div', attrs={'class': 'entry__likes'})
    ]

    feeds = [('\u0421\u043D\u043E\u0431', 'https://snob.ru/rss/')]

    def get_article_url(self, article):
        link = article.get('link', None)
        if 'utm_source' in link:
            return link.split('?utm')[0]
